package org.yxj.storagefilemobile;

import android.content.ContentUris;
import android.content.UriMatcher;
import android.net.Uri;

/**
 * @author on 2024/7/8
 */
public class LearnUri {

    private static final int PEOPLE = 1;
    private static final int PEOPLE_ID = 2;
    private static final int PEOPLE_PHONES = 3;
    private static final int PEOPLE_PHONES_ID = 4;
    private static final int PEOPLE_CONTACTMETHODS = 7;
    private static final int PEOPLE_CONTACTMETHODS_ID = 8;

    private static final int DELETED_PEOPLE = 20;

    private static final int PHONES = 9;
    private static final int PHONES_ID = 10;
    private static final int PHONES_FILTER = 14;

    private static final int CONTACTMETHODS = 18;
    private static final int CONTACTMETHODS_ID = 19;

    private static final int CALLS = 11;
    private static final int CALLS_ID = 12;
    private static final int CALLS_FILTER = 15;

    static UriMatcher sURIMatcher  = new UriMatcher(UriMatcher.NO_MATCH) ;

    static
    {
        sURIMatcher.addURI("contacts", "people", PEOPLE);
        sURIMatcher.addURI("contacts", "people/#", PEOPLE_ID);
        sURIMatcher.addURI("contacts", "people/#/phones", PEOPLE_PHONES);
        sURIMatcher.addURI("contacts", "people/#/phones/#", PEOPLE_PHONES_ID);
        sURIMatcher.addURI("contacts", "people/#/contact_methods", PEOPLE_CONTACTMETHODS);
        sURIMatcher.addURI("contacts", "people/#/contact_methods/#", PEOPLE_CONTACTMETHODS_ID);
        sURIMatcher.addURI("contacts", "deleted_people", DELETED_PEOPLE);
        sURIMatcher.addURI("contacts", "phones", PHONES);
        sURIMatcher.addURI("contacts", "phones/filter/*", PHONES_FILTER);
        sURIMatcher.addURI("contacts", "phones/#", PHONES_ID);
        sURIMatcher.addURI("contacts", "contact_methods", CONTACTMETHODS);
        sURIMatcher.addURI("contacts", "contact_methods/#", CONTACTMETHODS_ID);
        sURIMatcher.addURI("call_log", "calls", CALLS);
        sURIMatcher.addURI("call_log", "calls/filter/*", CALLS_FILTER);
        sURIMatcher.addURI("call_log", "calls/#", CALLS_ID);
    }



    public void checkUri(Uri uri) {
        switch (sURIMatcher.match(uri)){
            case PEOPLE:
                break;
        }
    }

    /*

    简称Uri
    通用资源标识符(Universal Resource Identifier)，Uri表示需要操作数据位置，Android上可用的资源(图像、音频、视频片段)都可以用Uri表示

    Uri三部分组成

    content://数据的路径/标识ID[指向某一具体项]（可选）
    例如：
    1.不带ID的Uri
    Images = content://media/external/images/media
    Audio = content://media/external/audio/media
    Video = content://media/external/video/media
    Downloads = content://media/external/downloads
    2.某个图片,带上id
    Uri：content://media/external/images/media/4


    Android 提供他了两个用于操作Uri的工具类，分别为UriMatcher 和ContentUris


    */


}
